package com.knowif.pojo;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.validation.constraints.NotEmpty;

import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.validation.annotation.Validated;

import com.knowif.enumInfo.InfoStatusEnum;

@Validated
public class TUser {
	
    private Integer id;

    /**
     * 创建时间
     */
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date createTime;

    /**
     * 姓名
     */
    private String fullName;

    /**
     * 是否删除
     */
    private Integer isDel;

    /**
     * 用户密码
     */
    private String password;

    /**
     * 用户类型
     */
    private Integer userType;

    /**
     * 用户名称
     */
    private String username;

    /**
     * 微信openid
     */
    @NotEmpty(message = "openid不能空")
    private String openid;

    /**
     * 用户头像
     */
    private String avatarUrl;

    /**
     * 微信昵称
     */
    private String nickName;

    /**
     * 性别1男2女
     */
    @NotEmpty(message = "性别不能为空")
    private Integer gender;

    /**
     * 电话号码
     */
    private String phoneNum;

    /**
     * 微信号
     */
    private String wechatNum;

    /**
     * 验证码
     */
    private String code;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Date getCreateTime() {
    	if(createTime == null){
    		createTime = new Date();
    	}
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public String getFullName() {
        return fullName;
    }

    public void setFullName(String fullName) {
        this.fullName = fullName == null ? null : fullName.trim();
    }

    //默认没有被删除状态为0
    public Integer getIsDel() {
    	if(isDel == null){
    		isDel = InfoStatusEnum.ISOK.getStatus();
    	}
        return isDel;
    }

    public void setIsDel(Integer isDel) {
        this.isDel = isDel;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password == null ? null : password.trim();
    }

    public Integer getUserType() {
        return userType;
    }

    public void setUserType(Integer userType) {
        this.userType = userType;
    }

    public String getUsername() {
        return username;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public void setUsername(String username) {
        this.username = username == null ? null : username.trim();
    }

    public String getOpenid() {
        return openid;
    }

    public void setOpenid(String openid) {
        this.openid = openid == null ? null : openid.trim();
    }

    public String getAvatarUrl() {
        return avatarUrl;
    }

    public void setAvatarUrl(String avatarUrl) {
        this.avatarUrl = avatarUrl == null ? null : avatarUrl.trim();
    }

    public String getNickName() {
        return nickName;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName == null ? null : nickName.trim();
    }

    public Integer getGender() {
        return gender;
    }

    public void setGender(Integer gender) {
        this.gender = gender;
    }

    public String getPhoneNum() {
        return phoneNum;
    }

    public void setPhoneNum(String phoneNum) {
        this.phoneNum = phoneNum == null ? null : phoneNum.trim();
    }

    public String getWechatNum() {
        return wechatNum;
    }

    public void setWechatNum(String wechatNum) {
        this.wechatNum = wechatNum;
    }

    public static List<Integer> getUserIds(List<TUser> tUsers){
    	if(tUsers == null || tUsers.isEmpty()){
    		return new ArrayList<Integer>();
    	}
    	List<Integer> userIds = new ArrayList<Integer>();
		for (TUser tUser : tUsers) {
			userIds.add(tUser.getId());
		}
		return userIds;
    }

    @Override
    public String toString() {
        return "TUser{" +
                "id=" + id +
                ", createTime=" + createTime +
                ", fullName='" + fullName + '\'' +
                ", isDel=" + isDel +
                ", password='" + password + '\'' +
                ", userType=" + userType +
                ", username='" + username + '\'' +
                ", openid='" + openid + '\'' +
                ", avatarUrl='" + avatarUrl + '\'' +
                ", nickName='" + nickName + '\'' +
                ", gender=" + gender +
                ", phoneNum='" + phoneNum + '\'' +
                ", wechatNum='" + wechatNum + '\'' +
                '}';
    }
}
    
